{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 上周学习内容\n",
    "* A.if else条件判断\n",
    "* B.循环嵌套 练习if elif\n",
    "* C.for循环 内置函数range()\n",
    "* D.使用\"dir\"查询一个对象\n",
    "* E.使用\"help\"读取Python文档\n",
    "* F.课本项目练习（奇数、\"for\"循环、啤酒歌谣）\n",
    "\n",
    "## 本周学习内容\n",
    "* A.jupyter notebook 扩展介绍\n",
    "> a. 使用目录，让工作更加便捷   \n",
    "> b. jupyter 的快捷使用\n",
    "* B.Python注释\n",
    "* C.用户输入"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### jupyter notebook 扩展介绍\n",
    "<font color=gray size=6> jupyter notebook键盘快捷键</font>"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "#### 进入命令模式之后（此时你没有活跃单元），你可以尝试以下快捷键：\n",
    "* A 会在活跃单元之上插入一个新的单元，B 会在活跃单元之下插入一个新单元。\n",
    "* 连续按两次 D，可以删除一个单元。\n",
    "* 撤销被删除的单元，按 Z。\n",
    "* Y 会将当前活跃的单元变成一个代码单元。\n",
    "* 按住 Shift +上或下箭头可选择多个单元。在多选模式时，按住 Shift + M 可合并你的选择。\n",
    "* 按 F 会弹出「查找和替换」菜单。\n",
    "___\n",
    "#### 处于编辑模式时（在命令模式时按 Enter 会进入编辑模式），你会发现下列快捷键很有用：\n",
    "* Ctrl + Home 到达单元起始位置。\n",
    "* Ctrl + S 保存进度。\n",
    "* 如之前提到的，Ctrl + Enter 会运行你的整个单元块。\n",
    "* Alt + Enter 不止会运行你的单元块，还会在下面添加一个新单元。\n",
    "* Ctrl + Shift + F 打开命令面板。"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Python注释"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "> 1. Python 支持两种类型的注释，分别是单行注释和多行注释；  \n",
    "> 2. 一般情况下，合理的代码注释应该占源代码的 1/3 左右；  \n",
    "> 3. 注释是用来向用户提示或解释某些代码的作用和功能，它可以出现在代码中的任何位置；  \n",
    "> 4. 在调试（Debug）程序的过程中，注释还可以用来临时移除无用的代码；  \n",
    "> 5. Python 解释器在执行代码时会忽略注释，不做任何处理，就好像它不存在一样。"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "#### 第一种注释"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {
    "scrolled": true
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Hello, world!\n"
     ]
    }
   ],
   "source": [
    "# 第一种注释\n",
    "print (\"Hello, world!\")"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "#### 第二种注释"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {
    "scrolled": true
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Hello, world!\n"
     ]
    }
   ],
   "source": [
    "'''\n",
    "第二种注释\n",
    "'''\n",
    "print (\"Hello, world!\")"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "#### 第三种注释"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {
    "scrolled": true
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Hello, world!\n"
     ]
    }
   ],
   "source": [
    "\"\"\"\n",
    "第三种注释\n",
    "\"\"\"\n",
    "print (\"Hello, world!\")"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 用户输入"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "> 1. input方法；    \n",
    "> 2. 字符串拼接+打印；    \n",
    "> 3. %s占位符的使用；    \n",
    "> 4. format方法。   "
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "#### F-01 初始 input"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "metadata": {
    "scrolled": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "username:weihonfen\n",
      "password:123\n",
      "weihonfen 123\n"
     ]
    }
   ],
   "source": [
    "# Author:WEI\n",
    "\n",
    "username = input(\"username:\")\n",
    "password = input(\"password:\")\n",
    "\n",
    "print(username,password)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "#### F-02 字符串拼接+打印："
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "metadata": {
    "scrolled": true
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "name:weihongfen\n",
      "age:20\n",
      "job:student\n",
      "salary:10000\n",
      "----- INFO OF weihongfen------\n",
      "age:20\n",
      "job:student\n",
      "salary:10000\n"
     ]
    }
   ],
   "source": [
    "# F-02 字符串拼接+打印：\n",
    "name = input(\"name:\")\n",
    "age = input(\"age:\")\n",
    "job = input(\"job:\")\n",
    "salary = input(\"salary:\")\n",
    "\n",
    "info = '''----- INFO OF ''' + name +'''------''' + '''\n",
    "age:''' + age+'''\n",
    "job:''' + job +'''\n",
    "salary:'''+salary\n",
    "\n",
    "print(info)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "* F-03 %s 使用（是不是很麻烦？有没有更简单的方式将打印内容？接下来我们来学习 %s 占位符。）\n",
    "\n",
    "> %s代表 string  \n",
    "> %d代表 number  \n",
    "> %f代表 float  \n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "#### F-03 %s 占位符 使用"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 21,
   "metadata": {
    "scrolled": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "name:weihongfen\n",
      "age:20\n",
      "job:student\n",
      "salary:10000\n",
      "-------INFO OF weihongfen -------\n",
      "Name:weihongfen\n",
      "Age:20\n",
      "Job:student\n",
      "Salary:10000\n",
      "\n"
     ]
    }
   ],
   "source": [
    "name = input(\"name:\")\n",
    "age = input(\"age:\")\n",
    "job = input(\"job:\")\n",
    "salary = input(\"salary:\")\n",
    "\n",
    "info = '''-------INFO OF %s -------\n",
    "Name:%s\n",
    "Age:%s\n",
    "Job:%s\n",
    "Salary:%s\n",
    "'''% (name,name,age,job,salary)\n",
    "\n",
    "print(info)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "#### F-04 * format方法"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "metadata": {
    "scrolled": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "-------INFO OF weihongfen -------\n",
      "Name:weihongfen\n",
      "Age:20\n",
      "Job:student\n",
      "Salary:10000\n",
      "\n"
     ]
    }
   ],
   "source": [
    "info2 =  '''-------INFO OF {_name} -------\n",
    "Name:{_name}\n",
    "Age:{_age}\n",
    "Job:{_job}\n",
    "Salary:{_salary}\n",
    "'''.format(_name=name,\n",
    "           _age=age,\n",
    "           _job=job,\n",
    "           _salary=salary)\n",
    "print(info2)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "#### 课本项目练习"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 20,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "weekday:Headache\n",
      "Work, work, work.\n"
     ]
    }
   ],
   "source": [
    "# Author:WEI\n",
    "\n",
    "today = input(\"weekday:\")\n",
    "if today == \"Saturday\":\n",
    "    print(\"Party!\")\n",
    "elif today == \"Sunday\":\n",
    "    condition = input(\"mood:\")\n",
    "    if condition == \"Headache\":\n",
    "        print(\"Recover, then rest.\")\n",
    "    else:\n",
    "        print(\"Rest.\")\n",
    "else:\n",
    "    print(\"Work, work, work.\")"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.8.3"
  },
  "toc": {
   "base_numbering": 1,
   "nav_menu": {},
   "number_sections": true,
   "sideBar": true,
   "skip_h1_title": false,
   "title_cell": "Table of Contents",
   "title_sidebar": "Contents",
   "toc_cell": false,
   "toc_position": {},
   "toc_section_display": true,
   "toc_window_display": true
  }
 },
 "nbformat": 4,
 "nbformat_minor": 4
}
